package com.example.demo.hutool.redis;



import redis.clients.jedis.Jedis;

import java.util.Scanner;

public class JedisPublisher {

    public static void main(String[] args) {

           start("channel1");
    }
    public static void start(String  channel){
        new Thread(()->{
            Jedis jedis =  RedisTypeTest.getJedisPool().getResource();
            while (true) {
                System.out.print("请输入即将发布的消息：");
                Scanner str = new Scanner(System.in);
                // 发布消息
                //返回订阅者数量
                String next = str.next();
                Long countSubscribe = jedis.publish("wwwsxm", next);
                System.out.println("发布成功，订阅数量:"+ countSubscribe);
            }
        }).start();
    }
}